#ifndef Engine_h__
#define Engine_h__

#include "Common/CommonTypes.h"

class CRenderSystem;
class CSceneManager;
class CHardwareResourceManager;
class CD3D10RenderDevice;

class CEngine
{
public:
	CEngine();
	~CEngine();

	void   Init(HWND hMainWnd, int nViewWidth, int nViewHeight);
	void   UnInit();

	void   Update(float fTime);
	void   Render();
	void   SwapBuffer();

	void   OnWindowResize(int nViewWidth, int nViewHeight);
	void   OnResetDevice();

public:
	INT32  GetViewWidth()    { return m_nViewWidth;  }
	INT32  GetViewHeight()   { return m_nViewHeight; }
	CMatrix GetViewMatrix()  { return m_mViewMatrix;  }
	CMatrix GetProjMatrix()  { return m_mProjMatrix;  }

	void   SetViewMatrix(const CMatrix& mViewMat) { m_mViewMatrix = mViewMat; }
	void   SetProjMatrix(const CMatrix& mProjMat) { m_mProjMatrix = mProjMat; }

public:
	CSceneManager*            GetSceneMgr();
	CRenderSystem*            GetRenderer();
	CHardwareResourceManager* GetHwResMgr(); 
	CD3D10RenderDevice*       GetRenderDevice();

private:
	void                     _InitRenderDevice(HWND hMainWnd, int nViewWidth, int nViewHeight);

private:
	INT32                      m_nViewWidth;
	INT32                      m_nViewHeight;
	CMatrix                    m_mViewMatrix;
	CMatrix                    m_mProjMatrix;
private:
	CRenderSystem*             m_pRenderer;
	CSceneManager*             m_pSceneMgr;
	CHardwareResourceManager*  m_pHWResMgr;
	CD3D10RenderDevice*        m_pRenderDevice;
};

CEngine* GetEngine();
void SetEngineInstance(CEngine* pEngine);

#endif // Engine_h__
